<?php
$aksi="modul/mod_kategori/aksi_kategori.php";
switch($_GET[act]){
  // Tampil Kategori
  default:
   ?>
<div id="toolbar-box">
	<div class="t">
		<div class="t">
			<div class="t"></div>
		</div>
	</div>
	<div class="m">
		<div class="toolbar" id="toolbar">
			<table class="toolbar">
            	<tr>
					<td class="button" id="toolbar-new">
  					<a href='?module=kategori&act=tambahkategori' onclick="javascript:hideMainMenu(); submitbutton('add')" class="toolbar">
  					<span class="icon-32-new" title="New">
  					</span>Tambah Kategori
  					</a>
					</td>
				</tr>
             </table>
		</div>
		<div class="header icon-48-addedit">Data Kategori</div>
			<div class="clr"></div>
			</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
</div>
  
 <? 
  
    echo "<table>
          <tr><th width=30px>no</th><th>nama kategori</th><th>aksi</th></tr>"; 
    $tampil=mysql_query("SELECT * FROM kategori_produk ORDER BY id_kategori DESC");
    $no=1;
    while ($r=mysql_fetch_array($tampil)){
       echo "<tr align='center'><td>$no</td>
             <td>$r[nama_kategori]</td>
             <td width=200px><a href=?module=kategori&act=editkategori&id=$r[id_kategori] class=tombol>Edit</a> | 
	               <a href=$aksi?module=kategori&act=hapus&id=$r[id_kategori] class=tombol onClick='return hapus()'>Hapus</a>
             </td></tr>";
      $no++;
    }
    echo "</table>";
    break;
  
  // Form Tambah Kategori
  case "tambahkategori":
  
  ?>
<div id="toolbar-box">
	<div class="t">
		<div class="t">
			<div class="t"></div>
		</div>
	</div>
	<div class="m">
		<div class="toolbar" id="toolbar">
			<table class="toolbar">
            	<tr>
					<td class="button" id="toolbar-new">
  					<a href=?module=kategori onclick="javascript: submitbutton('cancel')" class="toolbar"> <span class="icon-32-cancel" title="Cancel"></span>
Cancel</a></td>
  					<span class="icon-32-new" title="New">
  					</span>
  					</a>
					</td>
				</tr>
             </table>
		</div>
		<div class="header icon-48-addedit">Tambah Kategori</div>
			<div class="clr"></div>
			</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
</div>

<script type="text/javascript" src="js/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="js/jquery.validate.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#Form").validate({
		messages: {
			email: {
				required: "E-mail harus diisi",
				email: "Masukkan E-mail yang valid"
			}
		},
		errorPlacement: function(error, element) {
			error.appendTo(element.parent("td"));
		}
	});
})
</script>
<style type="text/css">
input.error, select.error { 
	border: 2px solid red;
	-moz-box-shadow:0 0 10px rgba(255, 0, 0, 0.6);
	-webkit-box-shadow:0 0 10px rgba(255, 0, 0, 0.6);
	}
label.error { color:red; margin-left: 10px; }
</style>
 <?
    echo " <form method=POST action='$aksi?module=kategori&act=input' id='Form'>
          <table>
          <tr><td width=150px>Nama Kategori</td><td> : <input type=text name='nama_kategori' class='required' title='&curren; Nama Kategori Harus diisi'></td></tr>
          <tr><td colspan=2><input type=submit name=submit value=Simpan class=tombol1>
                            <input type='reset' name'reset' value='Reset' class=tombol1></td></tr>
          </table></form>";
     break;
  
  // Form Edit Kategori  
  case "editkategori":
    ?>
<div id="toolbar-box">
	<div class="t">
		<div class="t">
			<div class="t"></div>
		</div>
	</div>
	<div class="m">
		<div class="toolbar" id="toolbar">
			<table class="toolbar">
            	<tr>
					<td class="button" id="toolbar-new">
  					<a href=?module=kategori onclick="javascript: submitbutton('cancel')" class="toolbar"> <span class="icon-32-cancel" title="Cancel"></span>
Cancel</a></td>
  					<span class="icon-32-new" title="New">
  					</span>
  					</a>
					</td>
				</tr>
             </table>
		</div>
		<div class="header icon-48-addedit">Edit Kategori</div>
			<div class="clr"></div>
			</div>
		<div class="b">
			<div class="b">
				<div class="b"></div>
			</div>
		</div>
</div>

<script type="text/javascript" src="js/jquery-1.2.3.pack.js"></script>
<script type="text/javascript" src="js/jquery.validate.pack.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#Form").validate({
		messages: {
			email: {
				required: "E-mail harus diisi",
				email: "Masukkan E-mail yang valid"
			}
		},
		errorPlacement: function(error, element) {
			error.appendTo(element.parent("td"));
		}
	});
})
</script>
<style type="text/css">
input.error, select.error { 
	border: 2px solid red;
	-moz-box-shadow:0 0 10px rgba(255, 0, 0, 0.6);
	-webkit-box-shadow:0 0 10px rgba(255, 0, 0, 0.6);
	}
label.error { color:red; margin-left: 10px; }
</style>
 <?
    $edit=mysql_query("SELECT * FROM kategori_produk WHERE id_kategori='$_GET[id]'");
    $r=mysql_fetch_array($edit);

    echo "<form method=POST action=$aksi?module=kategori&act=update id='Form'>
          <input type=hidden name=id value='$r[id_kategori]'>
          <table>
          <tr><td width=150px>Nama Kategori</td><td> : <input type=text name='nama_kategori' value='$r[nama_kategori]' class='required' title='&curren; Nama Kategori Harus diisi'></td></tr>
          <tr><td colspan=2><input type=submit value=Update class=tombol1>
                            <input type='reset' name'reset' value='Reset' class=tombol1></td></tr>
          </table></form>";
    break;  
}
?>
